//
//  Tools.m
//  MyWeChat
//
//  Created by 蔡欣东 on 15/10/9.
//  Copyright © 2015年 蔡欣东. All rights reserved.
//

#import "Tools.h"

@implementation Tools
+(void)showToast:(NSString*)message{
    UIWindow* window = [UIApplication sharedApplication].keyWindow;
    UIView* showView = [[UIView alloc]init];
    showView.backgroundColor = [UIColor clearColor];
    showView.frame = CGRectMake(1, 1, 1, 1);
    showView.alpha = 1.0f;
    showView.layer.cornerRadius = 5.0f;
    showView.layer.masksToBounds = YES;
    [window addSubview:showView];
    
    UILabel* label = [[UILabel alloc]init];
    CGSize labelSize = [message sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(290, 9000)];
    label.frame = CGRectMake(10, 5, labelSize.width, labelSize.height);
    label.text = message;
    label.textColor = [UIColor whiteColor];
    label.textAlignment = 1;
    label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont boldSystemFontOfSize:15];
    [showView addSubview:label];
    //showView.frame = CGRectMake((window.frame.size.width - labelSize.width - 20)/2, window.frame.size.width - 100, labelSize.width+20, labelSize.width+20);
    showView.frame = CGRectMake((window.frame.size.width - labelSize.width - 20)/2,70, labelSize.width+20, labelSize.height+20);
    [UIView animateWithDuration:2 animations:^{
        showView.alpha = 0;
    } completion:^(BOOL finished) {
        [showView removeFromSuperview];
    }];
}
@end
